package com.example.demo;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class RegexUtil
{
	
	public boolean isEmail(String str)
	{
		String pattern = "^[a-zA-Z][\\w\\.-]*[a-zA-Z0-9]@[a-zA-Z0-9][\\w\\.-]*[a-zA-Z0-9]\\.[a-zA-Z][a-zA-Z\\.]*[a-zA-Z]$";
		Pattern p = Pattern.compile(pattern);
		Matcher m = p.matcher(str);
		return m.matches();
	}
	
	public boolean isNumber(String str)
	{
		String pattern = "^[0-9]*$";
		Pattern p = Pattern.compile(pattern);
		Matcher m = p.matcher(str);
		return m.matches();
	}
}
